package com.chapter2.sort;

import java.util.Random;

/** 
 * @ClassName: ShuffleImpl 
 * @Description: TODO(这里用一句话描述这个类的作用) 
 * @author minjun minjun@bw30.com
 * @date 2015-2-16 下午3:40:05 
 *  
 */
public class ShuffleImpl extends SwapImpl implements Shuffle{

	@Override
	public void randomShuffle(int[] array) {
		Random random=new Random();
		for(int i=0;i<array.length;i++){
			int ran=random.nextInt(i+1);//knuth--从0--i取随机数，而不是从0-N
			exchange(array, ran, i);
		}
	}

}
